const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  entry: './src/toolball.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'toolball.min.js',
    library: 'ToolBallAPI',
    libraryTarget: 'umd',
    globalObject: 'this',
    clean: true
  },
  optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          compress: {
            drop_console: true,
            drop_debugger: true,
            pure_funcs: ['console.log', 'console.info', 'console.debug', 'console.warn']
          },
          mangle: {
            reserved: ['ToolBallAPI', 'initToolBall']
          },
          format: {
            comments: false
          }
        },
        extractComments: false
      })
    ]
  },
  mode: 'production',
  target: ['web', 'es5'],
  resolve: {
    extensions: ['.js']
  }
};
